package com.htu.controller;

import com.htu.constant.CResultType;
import com.htu.domain.Admin;
import com.htu.domain.Result;
import com.htu.model.IAdminModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AdminController
{
    @Autowired
    private IAdminModel model;

    @PostMapping("/adminLogin")
    public Result<Admin> doAdminLogin(String id, String password)
    {
        Admin admin = model.doAdminLogin(id, password);
        int resultType = CResultType.FAIL;
        String msg = "fail";
        if (admin != null)
        {
            resultType = CResultType.SUCCESS;
            msg = "success";
        }
        return new Result<Admin>(resultType, msg, admin);
    }

}
